package test.h0820;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main4 {
    //分数
    static class Fraction {
        int fa; //分母
        int son; //分子

        public Fraction() {
        }

        public Fraction(int fa, int son) {
            this.fa = fa;
            this.son = son;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        System.out.println(getRes(s));
    }


    private static String getRes(String s) {
        LinkedList<Fraction> op_nums = new LinkedList<>(); //操作数
        LinkedList<Character> op_chars = new LinkedList<>(); //操作符
        HashMap<Character, Integer> map = new HashMap<>();
        map.put('+', 1);
        map.put('-', 1);
        map.put('*', 2);
        map.put('/', 2);

        int i = 0;
        StringBuilder sb = new StringBuilder();
        while (i < s.length()) {
            char c = s.charAt(i);

            //遇到数字字符
            if (Character.isDigit(c)) {
                sb = new StringBuilder(); //重置缓冲器
                //因为有可能数位不是1
                while (Character.isDigit(c)) {
                    sb.append(c);
                    if (i + 1 >= s.length()) {
                        break;
                    }
                    i++;
                    c = s.charAt(i);
                }
                op_nums.addLast(new Fraction(1, Integer.parseInt(sb.toString())));
            }
            //如果是运算符
            if (c == '+' || c == '-' || c == '*' || c == '/') {
                //这里使用while循环，直到当前操作符优先级大于栈顶
                while (!op_chars.isEmpty() && op_chars.peekLast() != '(' && map.get(c) <= map.get(op_chars.peekLast())) {
                    Character ch = op_chars.removeLast();
                    Fraction f1 = op_nums.removeLast();
                    Fraction f2 = op_nums.removeLast();
                    op_nums.addLast(calculate(f1, f2, ch));
                }
                op_chars.addLast(c);
            }
            if (c == '(') {
                op_chars.addLast(c);
            }
            if (c == ')') {
                while (op_chars.peekLast() != '(') {
                    Character op = op_chars.removeLast();
                    Fraction f1 = op_nums.removeLast();
                    Fraction f2 = op_nums.removeLast();
                    op_nums.addLast(calculate(f1, f2, op));
                }
                //这里得将( 出栈
                op_chars.removeLast();
            }
            i++;
        }

        while (op_nums.size() > 1) {
            Character op = op_chars.removeLast();
            Fraction calculate = calculate(op_nums.removeLast(), op_nums.removeLast(), op);
            op_nums.addLast(calculate);
        }
        Fraction res = op_nums.removeLast();
        if (res.fa == 0) {
            return "ERROR";
        }
        //进行约分
        int fa = res.fa;
        int son = res.son;
        int factor = gcd(fa, son);
        long i1 = (long) fa * son;
        String sign = i1 < 0 ? "-" : "";
        int b = Math.abs(fa / factor);
        int a = Math.abs(son / factor);
        if (b != 1) {
            return sign + a + "/" + b;
        } else {
            return sign + a;
        }
    }

    private static int gcd(int fa, int son) {
        fa = Math.abs(fa);
        son = Math.abs(son);
        while (son != 0) {
            int temp = fa % son;
            fa = son;
            son = temp;
        }
        return fa;
    }

    private static Fraction calculate(Fraction f1, Fraction f2, Character op) {
        Fraction ans = new Fraction();
        if (op == '+') {
            ans.son = f1.son * f2.fa + f2.son * f1.fa; //分子
            ans.fa = f1.fa * f2.fa; //分母
        } else if (op == '-') {
            //减法先出来的是减数
            ans.son = f2.son * f1.fa - f1.son * f2.fa; //分子
            ans.fa = f1.fa * f2.fa; //分母
        } else if (op == '*') {
            ans.son = f1.son * f2.son; //分子
            ans.fa = f1.fa * f2.fa; //分母
        } else if (op == '/') {
            //除法的话，先出来的是除数
            ans.son = f2.son * f1.fa; //分子
            ans.fa = f2.fa * f1.son; //分母
        }
        return ans;
    }
}















